<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   template="../WEB-INF/shared/masterlayout.xhtml"
   xmlns:c="http://java.sun.com/jsp/jstl/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:f="http://java.sun.com/jsf/core">
  <ui:define name="leftCol">
    <ui:include src="components/leftCol.xhtml"/>
  </ui:define>
  <ui:define name="rightCol">
      <div class="reservation">
          <h1>Valj en flygning</h1>
          #{CompleteReservationBean.load()}
          <h:dataTable value="#{CompleteReservationBean.flights}" var="flight" styleClass="selectFlight">
              <h:column>
                <f:facet name="header">
                    <h:outputText value="Tid och datum"/>
                </f:facet>
                  Avgang: <h:outputText value="#{flight.starttime}"/>, <h:outputText value="#{flight.startdate}"/> <br/>
                  Ankomst: <h:outputText value="#{flight.endtime}"/>, <h:outputText value="#{flight.enddate}"/>
              </h:column>
              <h:column>
                <f:facet name="header">
                    <h:outputText value="Fran"/>
                </f:facet>
                <h:outputText value="#{flight.flightPK.fromdestination}"/> (<h:outputText value="#{flight.flightPK.fromairport}"/>)
              </h:column>
              <h:column>
                <f:facet name="header">
                    <h:outputText value="Till"/>
                </f:facet>
                <h:outputText value="#{flight.todestination}"/> (<h:outputText value="#{flight.toairport}"/>)
              </h:column>
              <h:column>
                <f:facet name="header">
                    <h:outputText value="Pris"/>
                </f:facet>
                  <h:outputText value="#{flight.price}"/>
              </h:column>
              <h:column>
                  <f:facet name="header">
                    <h:outputText value="Boka"/>
                  </f:facet>
                  <c:if test="#{LoginBean.loggedIn}">
                      <h:form>
                      <h:commandLink value="Reservera flygning"
                                     action="#{ReservationBean.navigateComplete}">
                          <f:setPropertyActionListener target="#{ReservationBean.flight}" value="#{flight}" />
                      </h:commandLink>
                      </h:form>
                  </c:if>
                  <c:if test="#{!LoginBean.loggedIn}">
                      <p>Du maste vara inloggad for att boka.</p>
                  </c:if>
              </h:column>
          </h:dataTable>
      </div>
  </ui:define>
</ui:composition>